#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@author: yuejl
@application:
@contact: lewyuejian@163.com
@file: api_read_config.py
@time: 2021/8/12 0012 23:29
@desc:
'''
from common.models import IConfig
import configparser as ConfigParser

class ReadConfig(object):
    __instance = None
    __inited = None

    def __new__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance=object.__new__(cls)
        return cls.__instance

    def __init__(self):
        if self.__inited is None:
            self.config = self._readConfig(r'D:\CodeBase\auto\AutomationAPI\conf\test.conf')

    def _readConfig(self, configFile):
        config = ConfigParser.ConfigParser()
        config.read(configFile, encoding='utf-8')
        Config = IConfig
        Config.url = config.get('host', 'stg_url')
        Config.init = config.get('isInit', 'init')
        return Config

if __name__ == '__main__':
    api = ReadConfig()
    print(api.config.url)